package com.lxd.property.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lxd.property.pojo.Powerroom;
import com.lxd.property.service.PowerroomService;
import com.lxd.property.utils.Page;

@Controller
@RequestMapping("powerroom")
public class PowerroomController {

	@Autowired
	private PowerroomService powerroomService;

	@RequestMapping(value = "getPowerroomList.do", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> getPowerroomList(Page page,
			@RequestParam(value = "startDate", required = false) String startDate,
			@RequestParam(value = "endDate", required = false) String endDate) {

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("start", page.getStart());
		map.put("rows", page.getRows());
		map.put("startDate", startDate);
		map.put("endDate", endDate);
		return powerroomService.getPowerroomList(map);
	}

	@RequestMapping(value = "getLastPowerroom.do", method = RequestMethod.POST)
	@ResponseBody
	public Powerroom getLastPowerroom() {
		return powerroomService.getLastPowerroom();
	}
	
	@RequestMapping(value = "addPowerroom.do", method = RequestMethod.POST)
	@ResponseBody
	public Boolean addPowerroom(Powerroom powerroom) {
		// TODO Auto-generated method stub
		return powerroomService.addPowerroom(powerroom)==1;
	}
	
	@RequestMapping(value = "findPowerroomById.do", method = RequestMethod.POST)
	@ResponseBody
	public Powerroom findPowerroomById(Integer id){
		return powerroomService.findPowerroomById(id);
	}
}
